# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 60
n 60(None)[self.template = None
return None
]:
	i: 31(), 44()
	o: 

nname: 44
n 44(None)[self.config = copy(default_config)
]:
	i: 0&15(f)
	o: 60()

nname: 31
n 31(None)[self.config = ConfigurationInfos
]:
	i: 0&15(t)
	o: 60()

nname: 0&15
n 0&15(ConfigurationInfos and isinstance(ConfigurationInfos, dict))[self.name = name
]:
	i: 
	o: 31(t), 44(f)

nname: 0&15
n 0&15(None)[self.name = name
if ConfigurationInfos and isinstance(ConfigurationInfos, dict):
	self.config = ConfigurationInfos
else:
	self.config = copy(default_config)
self.template = None
return None
]:
	i: 
	o: 

self.nodes: {'0&15': <unpyclib.structure.node instance at 0xb7530f4c>}
nname: 195
n 195(None)[return _name
]:
	i: 138(), 180(), 194()
	o: 

nname: 194
n 194(None)[]:
	i: 152(f)
	o: 195()

nname: 180
n 180(None)[_name += '-man'
]:
	i: 152(t)
	o: 195()

nname: 152
n 152(self.config.get('ipConfigType', '') == 'static')[]:
	i: 111(f)
	o: 180(t), 194(f)

nname: 138
n 138(None)[_name += '-auto'
]:
	i: 111(t)
	o: 195()

nname: 111
n 111(self.config.get('ipConfigType', '') == 'upnp')[]:
	i: 33(), 71(), 110()
	o: 138(t), 152(f)

nname: 110
n 110(None)[]:
	i: 43(f)
	o: 111()

nname: 71
n 71(None)[_name = 'Wifi'
_name += '-%s' % self.config.get('essid', '')
]:
	i: 43(t)
	o: 111()

nname: 43
n 43(self.config.get('networkType', '') == '802.11')[]:
	i: 0(f)
	o: 71(t), 110(f)

nname: 33
n 33(None)[_name = 'Eth'
]:
	i: 0(t)
	o: 111()

nname: 0
n 0(self.config.get('networkType', '') == '802.3')[_name = ''
]:
	i: 
	o: 33(t), 43(f)

nname: 195
n 195(None)[return _name
]:
	i: 0()
	o: 

nname: 0
n 0(None)[_name = ''
if self.config.get('networkType', '') == '802.3':
	_name = 'Eth'
else:
	if self.config.get('networkType', '') == '802.11':
		_name = 'Wifi'
		_name += '-%s' % self.config.get('essid', '')
if self.config.get('ipConfigType', '') == 'upnp':
	_name += '-auto'
else:
	if self.config.get('ipConfigType', '') == 'static':
		_name += '-man'
]:
	i: 
	o: 195()

nname: 0
n 0(None)[_name = ''
if self.config.get('networkType', '') == '802.3':
	_name = 'Eth'
else:
	if self.config.get('networkType', '') == '802.11':
		_name = 'Wifi'
		_name += '-%s' % self.config.get('essid', '')
if self.config.get('ipConfigType', '') == 'upnp':
	_name += '-auto'
else:
	if self.config.get('ipConfigType', '') == 'static':
		_name += '-man'
return _name
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75463cc>}
nname: 56
n 56(None)[]:
	i: 0(AL), 55()
	o: 

nname: 55
n 55(None)[]:
	i: 3(AF), 51()
	o: 56()

nname: 51
n 51(None)[]:
	i: 19(f), 37()
	o: 55()

nname: 37
n 37(None)[del self.config[key]
continue
]:
	i: 19(t)
	o: 51()

nname: 19
n 19(key not in self.template)[for key in self.config.keys():
]:
	i: 3(for)
	o: 37(t), 51(f)

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 19(for), 55(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 56(AL)

nname: 56
n 56(None)[]:
	i: 0(AL), 3(AF), 19()
	o: 

nname: 19
n 19(None)[for key in self.config.keys():
if key not in self.template:
	del self.config[key]
	continue
]:
	i: 3(for)
	o: 56()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 19(for), 56(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 56(AL)

nname: 19
n 19(None)[for key in self.config.keys():
	if key not in self.template:
		del self.config[key]
		continue
]:
	i: 0(for)
	o: 

nname: 0
n 0(None)[]:
	i: 
	o: 19(for)

nname: 0
n 0(None)[for key in self.config.keys():
	if key not in self.template:
		del self.config[key]
		continue
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7530e0c>}
nname: 263
n 263(None)[return None
]:
	i: 174(JA), 188(JA), 231(), 234()
	o: 

nname: 234
n 234(None)[log.error('config must be a dict: %s', self.config)
self.template = None
]:
	i: 0&30(f)
	o: 263()

nname: 231
n 231(None)[]:
	i: 229(AE)
	o: 263()

nname: 229
n 229(None)[]:
	i: 178(f)
	o: 231(AE)

nname: 188
n 188(None)[#, e
log.error('no template match your config')
PRINT_EXCEPTION(e)
self.template = None
]:
	i: 178(t)
	o: 263(JA)

nname: 178
n 178(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 49(except)
	o: 188(t), 229(f)

nname: 174
n 174(None)[]:
	i: 53(AL), 173()
	o: 263(JA)

nname: 173
n 173(None)[]:
	i: 78(AF), 169()
	o: 174()

nname: 169
n 169(None)[]:
	i: 85(f), 139()
	o: 173()

nname: 139
n 139(None)[tu_value = tpl_updaters[tu_key]
self.template.update(tu_value)
continue
]:
	i: 85(t)
	o: 169()

nname: 85
n 85(self.config.get(trigger_key, '') == trigger_value)[for tu_key in tu_keys:
pos, trigger_key, trigger_value = tu_key.split('_')
]:
	i: 78(for)
	o: 139(t), 169(f)

nname: 78
n 78(None)[]:
	i: 53(loop)
	o: 85(for), 173(AF)

nname: 53
n 53(None)[tu_keys = tpl_updaters.keys()
tu_keys.sort()
]:
	i: 49(try)
	o: 78(loop), 174(AL)

nname: 49
n 49(None)[]:
	i: 0&30(t)
	o: 53(try), 178(except)

nname: 0&30
n 0&30(self.config != None and isinstance(self.config, dict))[self.template = copy(tpl_base)
]:
	i: 
	o: 49(t), 234(f)

nname: 263
n 263(None)[return None
]:
	i: 188(JA), 234(), 178(f), 53(AL), 78(AF), 85(), 229(AE)
	o: 

nname: 234
n 234(None)[log.error('config must be a dict: %s', self.config)
self.template = None
]:
	i: 0&30(f)
	o: 263()

nname: 188
n 188(None)[#, e
log.error('no template match your config')
PRINT_EXCEPTION(e)
self.template = None
]:
	i: 178(t)
	o: 263(JA)

nname: 178
n 178(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 49(except)
	o: 188(t), 263(f)

nname: 85
n 85(None)[for tu_key in tu_keys:
pos, trigger_key, trigger_value = tu_key.split('_')
if self.config.get(trigger_key, '') == trigger_value:
	tu_value = tpl_updaters[tu_key]
	self.template.update(tu_value)
	continue
]:
	i: 78(for)
	o: 263()

nname: 78
n 78(None)[]:
	i: 53(loop)
	o: 85(for), 263(AF)

nname: 53
n 53(None)[tu_keys = tpl_updaters.keys()
tu_keys.sort()
]:
	i: 49(try)
	o: 78(loop), 263(AL)

nname: 49
n 49(None)[]:
	i: 0&30(t)
	o: 53(try), 178(except)

nname: 0&30
n 0&30(self.config != None and isinstance(self.config, dict))[self.template = copy(tpl_base)
]:
	i: 
	o: 49(t), 234(f)

nname: 263
n 263(None)[return None
]:
	i: 234(), 178(f), 78()
	o: 

nname: 234
n 234(None)[log.error('config must be a dict: %s', self.config)
self.template = None
]:
	i: 0&30(f)
	o: 263()

nname: 178
n 178(None)[except Exception, e:
	log.error('no template match your config')
	PRINT_EXCEPTION(e)
	self.template = None
]:
	i: 49()
	o: 263(JA)

nname: 78
n 78(None)[for tu_key in tu_keys:
	pos, trigger_key, trigger_value = tu_key.split('_')
	if self.config.get(trigger_key, '') == trigger_value:
		tu_value = tpl_updaters[tu_key]
		self.template.update(tu_value)
		continue
]:
	i: 49(loop)
	o: 263()

nname: 49
n 49(None)[try:
	tu_keys = tpl_updaters.keys()
	tu_keys.sort()
]:
	i: 0&30(t)
	o: 78(loop), 178()

nname: 0&30
n 0&30(self.config != None and isinstance(self.config, dict))[self.template = copy(tpl_base)
]:
	i: 
	o: 49(t), 234(f)

self.nodes: {263: <unpyclib.structure.node instance at 0xb7546bcc>, 234: <unpyclib.structure.node instance at 0xb7546e6c>, 78: <unpyclib.structure.node instance at 0xb754218c>, 49: <unpyclib.structure.node instance at 0xb754254c>, 178: <unpyclib.structure.node instance at 0xb7542bec>, '0&30': <unpyclib.structure.node instance at 0xb75428ec>}
nname: 0
n 0(None)[return '<%s::%s:%s %s>' % (self.__class__.__name__, repr(self.name), repr(self.autoname), self.config)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7530d4c>}
nname: 0
n 0(None)[self.config[key] = value
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7530c0c>}
nname: 0
n 0(None)[return self.config[key]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7530d4c>}
nname: 0
n 0(None)[return key in self.config
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7530aec>}
nname: 191
n 191(None)[return False
]:
	i: 28(), 98(), 161(), 182(), 190()
	o: 

nname: 190
n 190(None)[]:
	i: 169(f)
	o: 191()

nname: 182
n 182(None)[return True
]:
	i: 169(t)
	o: 191()

nname: 169
n 169(t_val == ())[]:
	i: 149(f)
	o: 182(t), 190(f)

nname: 161
n 161(None)[return True
]:
	i: 149(t)
	o: 191()

nname: 149
n 149(c_val in t_val)[]:
	i: 140(), 148()
	o: 161(t), 169(f)

nname: 148
n 148(None)[]:
	i: 111&127(f)
	o: 149()

nname: 140
n 140(None)[return False
]:
	i: 111&127(t)
	o: 149()

nname: 111&127
n 111&127(not isinstance(c_val, basestring) or c_val == '')[]:
	i: 71(), 109(AE)
	o: 140(t), 148(f)

nname: 109
n 109(None)[]:
	i: 88(f)
	o: 111&127(AE)

nname: 98
n 98(None)[return can_be_ommitted
]:
	i: 88(t)
	o: 191()

nname: 88
n 88(<dummy_ex3> EXC_MATCH KeyError)[]:
	i: 55(except)
	o: 98(t), 109(f)

nname: 71
n 71(None)[c_val = self.config[key]
]:
	i: 55(try)
	o: 111&127()

nname: 55
n 55(None)[can_be_ommitted = None in t_val
]:
	i: 0(t)
	o: 71(try), 88(except)

nname: 28
n 28(None)[log.error('template[%s] is not a tuple: %s', key, t_val)
return False
]:
	i: 0(f)
	o: 191()

nname: 0
n 0(isinstance(t_val, tuple))[t_val = self.template[key]
]:
	i: 
	o: 28(f), 55(t)

nname: 191
n 191(None)[return False
]:
	i: 28(), 98(), 111&127(), 88(f)
	o: 

nname: 98
n 98(None)[return can_be_ommitted
]:
	i: 88(t)
	o: 191()

nname: 88
n 88(<dummy_ex3> EXC_MATCH KeyError)[]:
	i: 55(except)
	o: 98(t), 191(f)

nname: 111&127
n 111&127(None)[if not isinstance(c_val, basestring) or c_val == '':
	return False
if c_val in t_val:
	return True
else:
	if t_val == ():
		return True
]:
	i: 71(), 109(AE)
	o: 191()

nname: 71
n 71(None)[c_val = self.config[key]
]:
	i: 55(try)
	o: 111&127()

nname: 55
n 55(None)[can_be_ommitted = None in t_val
]:
	i: 0(t)
	o: 71(try), 88(except)

nname: 28
n 28(None)[log.error('template[%s] is not a tuple: %s', key, t_val)
return False
]:
	i: 0(f)
	o: 191()

nname: 0
n 0(isinstance(t_val, tuple))[t_val = self.template[key]
]:
	i: 
	o: 28(f), 55(t)

nname: 191
n 191(None)[return False
]:
	i: 28(), 88()
	o: 

nname: 88
n 88(None)[except KeyError:
	return can_be_ommitted
else:
	if not isinstance(c_val, basestring) or c_val == '':
		return False
	if c_val in t_val:
		return True
	else:
		if t_val == ():
			return True
]:
	i: 55()
	o: 191()

nname: 55
n 55(None)[can_be_ommitted = None in t_val
try:
	c_val = self.config[key]
]:
	i: 0(t)
	o: 88()

nname: 28
n 28(None)[log.error('template[%s] is not a tuple: %s', key, t_val)
return False
]:
	i: 0(f)
	o: 191()

nname: 0
n 0(isinstance(t_val, tuple))[t_val = self.template[key]
]:
	i: 
	o: 28(f), 55(t)

nname: 191
n 191(None)[return False
]:
	i: 28(), 55()
	o: 

nname: 55
n 55(None)[can_be_ommitted = None in t_val
try:
	c_val = self.config[key]
except KeyError:
	return can_be_ommitted
else:
	if not isinstance(c_val, basestring) or c_val == '':
		return False
	if c_val in t_val:
		return True
	else:
		if t_val == ():
			return True
]:
	i: 0(t)
	o: 191()

nname: 28
n 28(None)[log.error('template[%s] is not a tuple: %s', key, t_val)
return False
]:
	i: 0(f)
	o: 191()

nname: 0
n 0(isinstance(t_val, tuple))[t_val = self.template[key]
]:
	i: 
	o: 28(f), 55(t)

nname: 0
n 0(None)[t_val = self.template[key]
if not isinstance(t_val, tuple):
	log.error('template[%s] is not a tuple: %s', key, t_val)
	return False
else:
	can_be_ommitted = None in t_val
	try:
		c_val = self.config[key]
	except KeyError:
		return can_be_ommitted
	else:
		if not isinstance(c_val, basestring) or c_val == '':
			return False
		if c_val in t_val:
			return True
		else:
			if t_val == ():
				return True
return False
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75467ac>}
nname: 0
n 0(None)[self.config['networkType'] = '802.3'
self._update_template()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7530e4c>}
nname: 155
n 155(None)[log.debug('template: %s', self.template)
]:
	i: 29(AL), 114(), 118()
	o: 

nname: 118
n 118(None)[self.config['hidden'] = 'true'
log.debug('set hidden = true')
self._update_template()
]:
	i: 0(f)
	o: 155()

nname: 114
n 114(None)[]:
	i: 33(AF), 110()
	o: 155()

nname: 110
n 110(None)[]:
	i: 46&70(f), 83()
	o: 114()

nname: 83
n 83(None)[self.config[net_key] = net_value
self._update_template()
continue
]:
	i: 46&70(t)
	o: 110()

nname: 46&70
n 46&70(net_key in self.template and net_value != '')[for net_key, net_value in NetworkInfos.iteritems():
]:
	i: 33(for)
	o: 83(t), 110(f)

nname: 33
n 33(None)[]:
	i: 29(loop)
	o: 46&70(for), 114(AF)

nname: 29
n 29(None)[]:
	i: 0(t)
	o: 33(loop), 155(AL)

nname: 0
n 0(NetworkInfos)[self.config['networkType'] = '802.11'
self._update_template()
]:
	i: 
	o: 29(t), 118(f)

nname: 155
n 155(None)[log.debug('template: %s', self.template)
]:
	i: 29(AL), 118(), 33(AF), 46&70(f)
	o: 

nname: 118
n 118(None)[self.config['hidden'] = 'true'
log.debug('set hidden = true')
self._update_template()
]:
	i: 0(f)
	o: 155()

nname: 46&70
n 46&70(None)[for net_key, net_value in NetworkInfos.iteritems():
if net_key in self.template and net_value != '':
	self.config[net_key] = net_value
	self._update_template()
	continue
]:
	i: 33(for)
	o: 155()

nname: 33
n 33(None)[]:
	i: 29(loop)
	o: 46&70(for), 155(AF)

nname: 29
n 29(None)[]:
	i: 0(t)
	o: 33(loop), 155(AL)

nname: 0
n 0(NetworkInfos)[self.config['networkType'] = '802.11'
self._update_template()
]:
	i: 
	o: 29(t), 118(f)

nname: 155
n 155(None)[log.debug('template: %s', self.template)
]:
	i: 118(), 46&70(f)
	o: 

nname: 118
n 118(None)[self.config['hidden'] = 'true'
log.debug('set hidden = true')
self._update_template()
]:
	i: 0(f)
	o: 155()

nname: 46&70
n 46&70(None)[for net_key, net_value in NetworkInfos.iteritems():
	if net_key in self.template and net_value != '':
		self.config[net_key] = net_value
		self._update_template()
		continue
]:
	i: 29(for)
	o: 155()

nname: 29
n 29(None)[]:
	i: 0(t)
	o: 46&70(for)

nname: 0
n 0(NetworkInfos)[self.config['networkType'] = '802.11'
self._update_template()
]:
	i: 
	o: 29(t), 118(f)

nname: 155
n 155(None)[log.debug('template: %s', self.template)
]:
	i: 118(), 29(f)
	o: 

nname: 118
n 118(None)[self.config['hidden'] = 'true'
log.debug('set hidden = true')
self._update_template()
]:
	i: 0(f)
	o: 155()

nname: 29
n 29(None)[for net_key, net_value in NetworkInfos.iteritems():
	if net_key in self.template and net_value != '':
		self.config[net_key] = net_value
		self._update_template()
		continue
]:
	i: 0(t)
	o: 155()

nname: 0
n 0(NetworkInfos)[self.config['networkType'] = '802.11'
self._update_template()
]:
	i: 
	o: 29(t), 118(f)

nname: 0
n 0(None)[self.config['networkType'] = '802.11'
self._update_template()
if NetworkInfos:
	for net_key, net_value in NetworkInfos.iteritems():
		if net_key in self.template and net_value != '':
			self.config[net_key] = net_value
			self._update_template()
			continue
else:
	self.config['hidden'] = 'true'
	log.debug('set hidden = true')
	self._update_template()
log.debug('template: %s', self.template)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75465cc>}
nname: 140
n 140(None)[]:
	i: 0(AL), 138()
	o: 

nname: 138
n 138(None)[]:
	i: 49(f), 115()
	o: 140()

nname: 115
n 115(None)[log.error('invalids dont change: configuration failed')
raise StopIteration
]:
	i: 55(f), 105()
	o: 138()

nname: 105
n 105(None)[invalids = invalids_new
continue
]:
	i: 55(t)
	o: 115()

nname: 55
n 55(invalids_new != invalids)[yield invalids[0]
invalids_new = self.invalids_keys()
log.debug('invalids_new=%s', invalids_new)
]:
	i: 49(t)
	o: 105(t), 115(f)

nname: 49
n 49(invalids)[]:
	i: 0(loop)
	o: 55(t), 138(f)

nname: 0
n 0(None)[log.debug('init')
yield None
invalids = self.invalids_keys()
log.debug('start invalids=%s', invalids)
]:
	i: 
	o: 49(loop), 140(AL)

nname: 140
n 140(None)[]:
	i: 0(AL), 49(f), 55()
	o: 

nname: 55
n 55(None)[yield invalids[0]
invalids_new = self.invalids_keys()
log.debug('invalids_new=%s', invalids_new)
if invalids_new != invalids:
	invalids = invalids_new
	continue
log.error('invalids dont change: configuration failed')
raise StopIteration
]:
	i: 49(t)
	o: 140()

nname: 49
n 49(invalids)[]:
	i: 0(loop)
	o: 55(t), 140(f)

nname: 0
n 0(None)[log.debug('init')
yield None
invalids = self.invalids_keys()
log.debug('start invalids=%s', invalids)
]:
	i: 
	o: 49(loop), 140(AL)

nname: 55
n 55(None)[	yield invalids[0]
	invalids_new = self.invalids_keys()
	log.debug('invalids_new=%s', invalids_new)
	if invalids_new != invalids:
		invalids = invalids_new
		continue
	log.error('invalids dont change: configuration failed')
	raise StopIteration
]:
	i: 0(t)
	o: 

nname: 0
n 0(invalids)[log.debug('init')
yield None
invalids = self.invalids_keys()
log.debug('start invalids=%s', invalids)
while invalids:
]:
	i: 
	o: 55(t)

nname: 0
n 0(None)[log.debug('init')
yield None
invalids = self.invalids_keys()
log.debug('start invalids=%s', invalids)
while invalids:
	yield invalids[0]
	invalids_new = self.invalids_keys()
	log.debug('invalids_new=%s', invalids_new)
	if invalids_new != invalids:
		invalids = invalids_new
		continue
	log.error('invalids dont change: configuration failed')
	raise StopIteration
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb754692c>}
nname: 77
n 77(None)[del _[1]
return invalids_keys_order
]:
	i: 0(AF), 74()
	o: 

nname: 74
n 74(None)[]:
	i: 58(JA), 69()
	o: 77()

nname: 69
n 69(None)[continue
[]
]:
	i: 24&42(f)
	o: 74()

nname: 58
n 58(None)[]:
	i: 24&42(f)
	o: 74(JA)

nname: 24&42
n 24&42(not key in self.template or self._valid_key(key))[for key in invalids_keys_order:
]:
	i: 0(for)
	o: 58(f), 69(t)

nname: 0
n 0(None)[self._update_template()
]:
	i: 
	o: 24&42(for), 77(AF)

nname: 77
n 77(None)[del _[1]
return invalids_keys_order
]:
	i: 0(AF), 24&42(JA)
	o: 

nname: 24&42
n 24&42(None)[for key in invalids_keys_order:
if not(not key in self.template or self._valid_key(key)):
	pass
else:
	continue
	[]
]:
	i: 0(for)
	o: 77(JA)

nname: 0
n 0(None)[self._update_template()
]:
	i: 
	o: 24&42(for), 77(AF)

self.nodes: {0: <unpyclib.structure.node instance at 0xb753fc0c>, '24&42': <unpyclib.structure.node instance at 0xb753fb8c>, 77: <unpyclib.structure.node instance at 0xb75467cc>}
nname: 100
n 100(None)[]:
	i: 61(), 75(), 98(AE)
	o: 

nname: 98
n 98(None)[]:
	i: 65(f)
	o: 100(AE)

nname: 75
n 75(None)[#, e
PRINT_EXCEPTION(e)
return False
]:
	i: 65(t)
	o: 100()

nname: 65
n 65(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 75(t), 98(f)

nname: 61
n 61(None)[]:
	i: 48(), 56()
	o: 100()

nname: 56
n 56(None)[return False
]:
	i: 3&16&26(f)
	o: 61()

nname: 48
n 48(None)[return True
]:
	i: 3&16&26(t)
	o: 61()

nname: 3&16&26
n 3&16&26(not self.invalids_keys() and self.name and len(self.name) > 0)[]:
	i: 0(try)
	o: 48(t), 56(f)

nname: 0
n 0(None)[]:
	i: 
	o: 3&16&26(try), 65(except)

nname: 100
n 100(None)[]:
	i: 65(), 0()
	o: 

nname: 65
n 65(None)[except Exception, e:
	PRINT_EXCEPTION(e)
	return False
]:
	i: 0()
	o: 100()

nname: 100
n 100(None)[]:
	i: 65(), 0()
	o: 

nname: 0
n 0(None)[try:
	if not self.invalids_keys() and self.name and len(self.name) > 0:
		return True
	else:
		return False
]:
	i: 
	o: 100(), 65()

self.nodes: {0: <unpyclib.structure.node instance at 0xb7546eac>, 100: <unpyclib.structure.node instance at 0xb7546d0c>, 65: <unpyclib.structure.node instance at 0xb7546f6c>}
nname: 34
n 34(None)[return True
]:
	i: 25(), 33()
	o: 

nname: 33
n 33(None)[]:
	i: 0&9(f)
	o: 34()

nname: 25
n 25(None)[return False
]:
	i: 0&9(t)
	o: 34()

nname: 0&9
n 0&9(self.name and self.name in ('Wireless', 'Ethernet'))[]:
	i: 
	o: 25(t), 33(f)

nname: 0&9
n 0&9(None)[if self.name and self.name in ('Wireless', 'Ethernet'):
	return False
return True
]:
	i: 
	o: 

self.nodes: {'0&9': <unpyclib.structure.node instance at 0xb7530b6c>}
nname: 6
n 6(None)[__doc__ = ' Use it to build a valid Wynetwork configuration. '
def __init__(self, name=None, ConfigurationInfos=None):
	self.name = name
	if ConfigurationInfos and isinstance(ConfigurationInfos, dict):
		self.config = ConfigurationInfos
	else:
		self.config = copy(default_config)
	self.template = None
	return None

def _get_autoname(self):
	_name = ''
	if self.config.get('networkType', '') == '802.3':
		_name = 'Eth'
	else:
		if self.config.get('networkType', '') == '802.11':
			_name = 'Wifi'
			_name += '-%s' % self.config.get('essid', '')
	if self.config.get('ipConfigType', '') == 'upnp':
		_name += '-auto'
	else:
		if self.config.get('ipConfigType', '') == 'static':
			_name += '-man'
	return _name

autoname = property(_get_autoname)
del _get_autoname
def cleanup(self):
	for key in self.config.keys():
		if key not in self.template:
			del self.config[key]
			continue

def _update_template(self):
	self.template = copy(tpl_base)

def __repr__(self):
	return '<%s::%s:%s %s>' % (self.__class__.__name__, repr(self.name), repr(self.autoname), self.config)

def __setitem__(self, key, value):
	self.config[key] = value

def __getitem__(self, key):
	return self.config[key]

def __contains__(self, key):
	return key in self.config

def _valid_key(self, key):
	t_val = self.template[key]
	if not isinstance(t_val, tuple):
		log.error('template[%s] is not a tuple: %s', key, t_val)
		return False
	else:
		can_be_ommitted = None in t_val
		try:
			c_val = self.config[key]
		except KeyError:
			return can_be_ommitted
		else:
			if not isinstance(c_val, basestring) or c_val == '':
				return False
			if c_val in t_val:
				return True
			else:
				if t_val == ():
					return True
	return False

def set_ethernet(self):
	self.config['networkType'] = '802.3'
	self._update_template()

def set_network(self, NetworkInfos):
	self.config['networkType'] = '802.11'
	self._update_template()
	if NetworkInfos:
		for net_key, net_value in NetworkInfos.iteritems():
			if net_key in self.template and net_value != '':
				self.config[net_key] = net_value
				self._update_template()
				continue
	else:
		self.config['hidden'] = 'true'
		log.debug('set hidden = true')
		self._update_template()
	log.debug('template: %s', self.template)

def configurator(self):
	log.debug('init')
	yield None
	invalids = self.invalids_keys()
	log.debug('start invalids=%s', invalids)
	while invalids:
		yield invalids[0]
		invalids_new = self.invalids_keys()
		log.debug('invalids_new=%s', invalids_new)
		if invalids_new != invalids:
			invalids = invalids_new
			continue
		log.error('invalids dont change: configuration failed')
		raise StopIteration

def invalids_keys(self):
	self._update_template()

def is_valid(self):
	try:
		if not self.invalids_keys() and self.name and len(self.name) > 0:
			return True
		else:
			return False

def is_removable(self):
	if self.name and self.name in ('Wireless', 'Ethernet'):
		return False
	return True

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb753062c>}
nname: 0
n 0(None)[self.wn_gen = wn.NetGeneral()
self.wn_dev = wn.NetDevices()
self.wn_net = wn.NetNetworks()
self.wn_cfg = wn.NetConfigurations()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7530bec>}
nname: 0
n 0(None)[self.wn_gen.attach(obs)
self.wn_dev.attach(obs)
self.wn_net.attach(obs)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75304ac>}
nname: 0
n 0(None)[self.wn_gen.detach(obs)
self.wn_dev.detach(obs)
self.wn_net.detach(obs)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75307ec>}
nname: 98
n 98(None)[]:
	i: 55(), 73(), 96(AE)
	o: 

nname: 96
n 96(None)[]:
	i: 63(f)
	o: 98(AE)

nname: 73
n 73(None)[#, e
PRINT_EXCEPTION(e)
return ()
]:
	i: 63(t)
	o: 98()

nname: 63
n 63(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 73(t), 96(f)

nname: 55
n 55(None)[del _[1]
return self.wn_dev.getDevices()
]:
	i: 3(AF), 26()
	o: 98()

nname: 26
n 26(None)[for dev in self.wn_dev.getDevices():
]:
	i: 3(for)
	o: 55()

nname: 3
n 3(None)[]:
	i: 0(try)
	o: 26(for), 55(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 63(except)

nname: 98
n 98(None)[]:
	i: 55(), 63()
	o: 

nname: 63
n 63(None)[except Exception, e:
	PRINT_EXCEPTION(e)
	return ()
]:
	i: 0()
	o: 98()

nname: 55
n 55(None)[del _[1]
return self.wn_dev.getDevices()
]:
	i: 0(AF), 26()
	o: 98()

nname: 26
n 26(None)[for dev in self.wn_dev.getDevices():
]:
	i: 0(for)
	o: 55()

nname: 0
n 0(None)[try:
	pass
]:
	i: 
	o: 26(for), 55(AF), 63()

self.nodes: {0: <unpyclib.structure.node instance at 0xb7530b8c>, 98: <unpyclib.structure.node instance at 0xb7530fcc>, 55: <unpyclib.structure.node instance at 0xb7530c0c>, 26: <unpyclib.structure.node instance at 0xb753066c>, 63: <unpyclib.structure.node instance at 0xb7530c8c>}
nname: 0
n 0(None)[return '802.11' in self.availables_networkType()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75304cc>}
nname: 149
n 149(None)[return cfgs
]:
	i: 114(), 128(), 147(AE)
	o: 

nname: 147
n 147(None)[]:
	i: 118(f)
	o: 149(AE)

nname: 128
n 128(None)[#, e
PRINT_EXCEPTION(e)
]:
	i: 118(t)
	o: 149()

nname: 118
n 118(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 128(t), 147(f)

nname: 114
n 114(None)[]:
	i: 21(AL), 113()
	o: 149()

nname: 113
n 113(None)[]:
	i: 24(AF), 109()
	o: 114()

nname: 109
n 109(None)[]:
	i: 40(f), 77()
	o: 113()

nname: 77
n 77(None)[cfgs.append(WyNetworkConfig(name=name, ConfigurationInfos=infos))
continue
]:
	i: 40(t)
	o: 109()

nname: 40
n 40(infos['networkType'] in net_types)[for name in self.wn_cfg.getConfigurations():
infos = self.wn_cfg.getConfigurationInfos(name)
]:
	i: 24(for)
	o: 77(t), 109(f)

nname: 24
n 24(None)[]:
	i: 21(loop)
	o: 40(for), 113(AF)

nname: 21
n 21(None)[]:
	i: 0(try)
	o: 24(loop), 114(AL)

nname: 0
n 0(None)[cfgs = []
net_types = self.availables_networkType()
]:
	i: 
	o: 21(try), 118(except)

nname: 149
n 149(None)[return cfgs
]:
	i: 118(), 0(AL), 24(AF), 40()
	o: 

nname: 118
n 118(None)[except Exception, e:
	PRINT_EXCEPTION(e)
]:
	i: 0()
	o: 149()

nname: 149
n 149(None)[return cfgs
]:
	i: 118(), 0(AL), 24(AF), 40()
	o: 

nname: 40
n 40(None)[for name in self.wn_cfg.getConfigurations():
infos = self.wn_cfg.getConfigurationInfos(name)
if infos['networkType'] in net_types:
	cfgs.append(WyNetworkConfig(name=name, ConfigurationInfos=infos))
	continue
]:
	i: 24(for)
	o: 149()

nname: 24
n 24(None)[]:
	i: 0(loop)
	o: 40(for), 149(AF)

nname: 0
n 0(None)[cfgs = []
net_types = self.availables_networkType()
try:
]:
	i: 
	o: 24(loop), 149(AL), 118()

self.nodes: {0: <unpyclib.structure.node instance at 0xb75464ac>, 40: <unpyclib.structure.node instance at 0xb7546f6c>, 118: <unpyclib.structure.node instance at 0xb7546d8c>, 24: <unpyclib.structure.node instance at 0xb7530eac>, 149: <unpyclib.structure.node instance at 0xb7546c4c>}
nname: 0
n 0(None)[return WyNetworkConfig(name=name, ConfigurationInfos=ConfigurationInfos)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75463cc>}
nname: 83
n 83(None)[]:
	i: 66(), 82()
	o: 

nname: 82
n 82(None)[]:
	i: 45(t)
	o: 83()

nname: 66
n 66(None)[raise Exception('deleteConfiguration() failed')
]:
	i: 45(f)
	o: 83()

nname: 45
n 45(self.wn_cfg.deleteConfiguration(config.name))[]:
	i: 28(), 44()
	o: 66(f), 82(t)

nname: 44
n 44(None)[]:
	i: 0(t)
	o: 45()

nname: 28
n 28(None)[raise Exception('config must be a WyNetworkConfig')
]:
	i: 0(f)
	o: 45()

nname: 0
n 0(isinstance(config, WyNetworkConfig))[log.debug(config)
]:
	i: 
	o: 28(f), 44(t)

nname: 83
n 83(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.debug(config)
if not isinstance(config, WyNetworkConfig):
	raise Exception('config must be a WyNetworkConfig')
if not self.wn_cfg.deleteConfiguration(config.name):
	raise Exception('deleteConfiguration() failed')
]:
	i: 
	o: 83()

nname: 0
n 0(None)[log.debug(config)
if not isinstance(config, WyNetworkConfig):
	raise Exception('config must be a WyNetworkConfig')
if not self.wn_cfg.deleteConfiguration(config.name):
	raise Exception('deleteConfiguration() failed')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7546f4c>}
nname: 217
n 217(None)[]:
	i: 184(), 216()
	o: 

nname: 216
n 216(None)[]:
	i: 157(t)
	o: 217()

nname: 184
n 184(None)[raise Exception('setConfigurationInfos(%s, %s) failed' % (config.name, config.config))
]:
	i: 157(f)
	o: 217()

nname: 157
n 157(self.wn_cfg.setConfigurationInfos(config.name, config.config))[]:
	i: 129(JA), 152(), 156()
	o: 184(f), 216(t)

nname: 156
n 156(None)[]:
	i: 83(f)
	o: 157()

nname: 152
n 152(None)[]:
	i: 107(t)
	o: 157()

nname: 129
n 129(None)[raise Exception('addConfiguration(%s) failed' % config.name)
]:
	i: 107(f)
	o: 157(JA)

nname: 107
n 107(self.wn_cfg.addConfiguration(config.name))[]:
	i: 83(t)
	o: 129(f), 152(t)

nname: 83
n 83(config.name not in self.wn_cfg.getConfigurations())[]:
	i: 57(), 82()
	o: 107(t), 156(f)

nname: 82
n 82(None)[]:
	i: 45(t)
	o: 83()

nname: 57
n 57(None)[raise Exception('invalid keys: %s', config.invalids_keys())
]:
	i: 45(f)
	o: 83()

nname: 45
n 45(config.is_valid())[]:
	i: 28(), 44()
	o: 57(f), 82(t)

nname: 44
n 44(None)[]:
	i: 0(t)
	o: 45()

nname: 28
n 28(None)[raise Exception('config must be a WyNetworkConfig')
]:
	i: 0(f)
	o: 45()

nname: 0
n 0(isinstance(config, WyNetworkConfig))[log.debug(config)
]:
	i: 
	o: 28(f), 44(t)

nname: 217
n 217(None)[]:
	i: 83()
	o: 

nname: 83
n 83(None)[if config.name not in self.wn_cfg.getConfigurations():
	if not self.wn_cfg.addConfiguration(config.name):
		raise Exception('addConfiguration(%s) failed' % config.name)
if not self.wn_cfg.setConfigurationInfos(config.name, config.config):
	raise Exception('setConfigurationInfos(%s, %s) failed' % (config.name, config.config))
]:
	i: 0()
	o: 217()

nname: 0
n 0(None)[log.debug(config)
if not isinstance(config, WyNetworkConfig):
	raise Exception('config must be a WyNetworkConfig')
if not config.is_valid():
	raise Exception('invalid keys: %s', config.invalids_keys())
]:
	i: 
	o: 83()

nname: 217
n 217(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.debug(config)
if not isinstance(config, WyNetworkConfig):
	raise Exception('config must be a WyNetworkConfig')
if not config.is_valid():
	raise Exception('invalid keys: %s', config.invalids_keys())
if config.name not in self.wn_cfg.getConfigurations():
	if not self.wn_cfg.addConfiguration(config.name):
		raise Exception('addConfiguration(%s) failed' % config.name)
if not self.wn_cfg.setConfigurationInfos(config.name, config.config):
	raise Exception('setConfigurationInfos(%s, %s) failed' % (config.name, config.config))
]:
	i: 
	o: 217()

nname: 0
n 0(None)[log.debug(config)
if not isinstance(config, WyNetworkConfig):
	raise Exception('config must be a WyNetworkConfig')
if not config.is_valid():
	raise Exception('invalid keys: %s', config.invalids_keys())
if config.name not in self.wn_cfg.getConfigurations():
	if not self.wn_cfg.addConfiguration(config.name):
		raise Exception('addConfiguration(%s) failed' % config.name)
if not self.wn_cfg.setConfigurationInfos(config.name, config.config):
	raise Exception('setConfigurationInfos(%s, %s) failed' % (config.name, config.config))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7546bec>}
nname: 112
n 112(None)[]:
	i: 95(), 111()
	o: 

nname: 111
n 111(None)[]:
	i: 74(t)
	o: 112()

nname: 95
n 95(None)[raise Exception('setActiveConfiguration() failed')
]:
	i: 74(f)
	o: 112()

nname: 74
n 74(self.wn_cfg.setActiveConfiguration(config.name))[]:
	i: 57(), 73()
	o: 95(f), 111(t)

nname: 73
n 73(None)[]:
	i: 45(t)
	o: 74()

nname: 57
n 57(None)[raise Exception('config is not valid')
]:
	i: 45(f)
	o: 74()

nname: 45
n 45(config.is_valid())[]:
	i: 28(), 44()
	o: 57(f), 73(t)

nname: 44
n 44(None)[]:
	i: 0(t)
	o: 45()

nname: 28
n 28(None)[raise Exception('config must be a WyNetworkConfig')
]:
	i: 0(f)
	o: 45()

nname: 0
n 0(isinstance(config, WyNetworkConfig))[log.debug(config)
]:
	i: 
	o: 28(f), 44(t)

nname: 74
n 74(None)[if not self.wn_cfg.setActiveConfiguration(config.name):
	raise Exception('setActiveConfiguration() failed')
]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.debug(config)
if not isinstance(config, WyNetworkConfig):
	raise Exception('config must be a WyNetworkConfig')
if not config.is_valid():
	raise Exception('config is not valid')
]:
	i: 
	o: 74()

nname: 0
n 0(None)[log.debug(config)
if not isinstance(config, WyNetworkConfig):
	raise Exception('config must be a WyNetworkConfig')
if not config.is_valid():
	raise Exception('config is not valid')
if not self.wn_cfg.setActiveConfiguration(config.name):
	raise Exception('setActiveConfiguration() failed')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb754678c>}
nname: 76
n 76(None)[]:
	i: 37(), 75()
	o: 

nname: 75
n 75(None)[]:
	i: 0&24(f)
	o: 76()

nname: 37
n 37(None)[config['interface'] = self.wn_dev.getDevicesByType(config['networkType'])[0]['interface']
]:
	i: 0&24(t)
	o: 76()

nname: 0&24
n 0&24(key == 'interface' and key in invalids)[invalids = config.invalids_keys()
]:
	i: 
	o: 37(t), 75(f)

nname: 0&24
n 0&24(None)[invalids = config.invalids_keys()
if key == 'interface' and key in invalids:
	config['interface'] = self.wn_dev.getDevicesByType(config['networkType'])[0]['interface']
]:
	i: 
	o: 

self.nodes: {'0&24': <unpyclib.structure.node instance at 0xb754646c>}
nname: 182
n 182(None)[return nets
]:
	i: 147(), 161(), 180(AE)
	o: 

nname: 180
n 180(None)[]:
	i: 151(f)
	o: 182(AE)

nname: 161
n 161(None)[#, e
PRINT_EXCEPTION(e)
]:
	i: 151(t)
	o: 182()

nname: 151
n 151(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 161(t), 180(f)

nname: 147
n 147(None)[]:
	i: 9(AL), 146()
	o: 182()

nname: 146
n 146(None)[]:
	i: 12(AF), 143()
	o: 147()

nname: 143
n 143(None)[]:
	i: 65(AL), 142()
	o: 146()

nname: 142
n 142(None)[]:
	i: 28(f), 138()
	o: 143()

nname: 138
n 138(None)[continue
]:
	i: 69(AF), 88()
	o: 142()

nname: 88
n 88(None)[for net in self.wn_net.getNetworks(dev):
net_infos = self.wn_net.getNetworkInfos(dev, net)
net_infos['interface'] = dev
nets.append(net_infos)
]:
	i: 69(for)
	o: 138()

nname: 69
n 69(None)[]:
	i: 65(loop)
	o: 88(for), 138(AF)

nname: 65
n 65(None)[]:
	i: 28(t)
	o: 69(loop), 143(AL)

nname: 28
n 28(dev_infos['networkType'] == '802.11')[for dev in self.wn_dev.getDevices():
dev_infos = self.wn_dev.getDeviceInfos(dev)
]:
	i: 12(for)
	o: 65(t), 142(f)

nname: 12
n 12(None)[]:
	i: 9(loop)
	o: 28(for), 146(AF)

nname: 9
n 9(None)[]:
	i: 0(try)
	o: 12(loop), 147(AL)

nname: 0
n 0(None)[nets = []
]:
	i: 
	o: 9(try), 151(except)

nname: 182
n 182(None)[return nets
]:
	i: 151(), 0(AL), 12(AF), 65(AL), 28(f), 138()
	o: 

nname: 151
n 151(None)[except Exception, e:
	PRINT_EXCEPTION(e)
]:
	i: 0()
	o: 182()

nname: 182
n 182(None)[return nets
]:
	i: 151(), 0(AL), 12(AF), 65(AL), 28(f), 138()
	o: 

nname: 138
n 138(None)[continue
]:
	i: 69(AF), 88()
	o: 182()

nname: 88
n 88(None)[for net in self.wn_net.getNetworks(dev):
net_infos = self.wn_net.getNetworkInfos(dev, net)
net_infos['interface'] = dev
nets.append(net_infos)
]:
	i: 69(for)
	o: 138()

nname: 69
n 69(None)[]:
	i: 65(loop)
	o: 88(for), 138(AF)

nname: 65
n 65(None)[]:
	i: 28(t)
	o: 69(loop), 182(AL)

nname: 28
n 28(dev_infos['networkType'] == '802.11')[for dev in self.wn_dev.getDevices():
dev_infos = self.wn_dev.getDeviceInfos(dev)
]:
	i: 12(for)
	o: 65(t), 182(f)

nname: 12
n 12(None)[]:
	i: 0(loop)
	o: 28(for), 182(AF)

nname: 0
n 0(None)[nets = []
try:
]:
	i: 
	o: 12(loop), 182(AL), 151()

nname: 182
n 182(None)[return nets
]:
	i: 151(), 0(AL), 12(AF), 28(f), 88()
	o: 

nname: 151
n 151(None)[except Exception, e:
	PRINT_EXCEPTION(e)
]:
	i: 0()
	o: 182()

nname: 182
n 182(None)[return nets
]:
	i: 151(), 0(AL), 12(AF), 28(f), 88()
	o: 

nname: 88
n 88(None)[for net in self.wn_net.getNetworks(dev):
	net_infos = self.wn_net.getNetworkInfos(dev, net)
	net_infos['interface'] = dev
	nets.append(net_infos)
else:
	continue
]:
	i: 65(for)
	o: 182()

nname: 65
n 65(None)[]:
	i: 28(t)
	o: 88(for)

nname: 28
n 28(dev_infos['networkType'] == '802.11')[for dev in self.wn_dev.getDevices():
dev_infos = self.wn_dev.getDeviceInfos(dev)
]:
	i: 12(for)
	o: 65(t), 182(f)

nname: 12
n 12(None)[]:
	i: 0(loop)
	o: 28(for), 182(AF)

nname: 0
n 0(None)[nets = []
try:
]:
	i: 
	o: 12(loop), 182(AL), 151()

nname: 182
n 182(None)[return nets
]:
	i: 151(), 0(AL), 12(AF), 28(f), 65()
	o: 

nname: 151
n 151(None)[except Exception, e:
	PRINT_EXCEPTION(e)
]:
	i: 0()
	o: 182()

nname: 182
n 182(None)[return nets
]:
	i: 151(), 0(AL), 12(AF), 28(f), 65()
	o: 

nname: 65
n 65(None)[for net in self.wn_net.getNetworks(dev):
	net_infos = self.wn_net.getNetworkInfos(dev, net)
	net_infos['interface'] = dev
	nets.append(net_infos)
else:
	continue
]:
	i: 28(t)
	o: 182()

nname: 28
n 28(dev_infos['networkType'] == '802.11')[for dev in self.wn_dev.getDevices():
dev_infos = self.wn_dev.getDeviceInfos(dev)
]:
	i: 12(for)
	o: 65(t), 182(f)

nname: 12
n 12(None)[]:
	i: 0(loop)
	o: 28(for), 182(AF)

nname: 0
n 0(None)[nets = []
try:
]:
	i: 
	o: 12(loop), 182(AL), 151()

nname: 182
n 182(None)[return nets
]:
	i: 151(), 0(AL), 12(AF), 28(f)
	o: 

nname: 151
n 151(None)[except Exception, e:
	PRINT_EXCEPTION(e)
]:
	i: 0()
	o: 182()

nname: 182
n 182(None)[return nets
]:
	i: 151(), 0(AL), 12(AF), 28(f)
	o: 

nname: 28
n 28(None)[for dev in self.wn_dev.getDevices():
dev_infos = self.wn_dev.getDeviceInfos(dev)
if dev_infos['networkType'] == '802.11':
	for net in self.wn_net.getNetworks(dev):
		net_infos = self.wn_net.getNetworkInfos(dev, net)
		net_infos['interface'] = dev
		nets.append(net_infos)
	else:
		continue
]:
	i: 12(for)
	o: 182()

nname: 12
n 12(None)[]:
	i: 0(loop)
	o: 28(for), 182(AF)

nname: 0
n 0(None)[nets = []
try:
]:
	i: 
	o: 12(loop), 182(AL), 151()

self.nodes: {0: <unpyclib.structure.node instance at 0xb753054c>, 12: <unpyclib.structure.node instance at 0xb754680c>, 182: <unpyclib.structure.node instance at 0xb753058c>, 151: <unpyclib.structure.node instance at 0xb753066c>, 28: <unpyclib.structure.node instance at 0xb75303ac>}
nname: 85
n 85(None)[]:
	i: 0(AL), 84()
	o: 

nname: 84
n 84(None)[]:
	i: 3(AF), 80()
	o: 85()

nname: 80
n 80(None)[]:
	i: 22(t), 50()
	o: 84()

nname: 50
n 50(None)[raise Exception('setScanningEnabled(%s, %s) failed' % (dev_infos['interface'], enabled))
continue
]:
	i: 22(f)
	o: 80()

nname: 22
n 22(self.wn_dev.setScanningEnabled(dev_infos['interface'], enabled))[for dev_infos in self.wn_dev.getDevicesByType('802.11'):
]:
	i: 3(for)
	o: 50(f), 80(t)

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 22(for), 84(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 85(AL)

nname: 85
n 85(None)[]:
	i: 0(AL), 3(AF), 22()
	o: 

nname: 22
n 22(None)[for dev_infos in self.wn_dev.getDevicesByType('802.11'):
if not self.wn_dev.setScanningEnabled(dev_infos['interface'], enabled):
	raise Exception('setScanningEnabled(%s, %s) failed' % (dev_infos['interface'], enabled))
	continue
]:
	i: 3(for)
	o: 85()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 22(for), 85(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 85(AL)

nname: 22
n 22(None)[for dev_infos in self.wn_dev.getDevicesByType('802.11'):
	if not self.wn_dev.setScanningEnabled(dev_infos['interface'], enabled):
		raise Exception('setScanningEnabled(%s, %s) failed' % (dev_infos['interface'], enabled))
		continue
]:
	i: 0(for)
	o: 

nname: 0
n 0(None)[]:
	i: 
	o: 22(for)

nname: 0
n 0(None)[for dev_infos in self.wn_dev.getDevicesByType('802.11'):
	if not self.wn_dev.setScanningEnabled(dev_infos['interface'], enabled):
		raise Exception('setScanningEnabled(%s, %s) failed' % (dev_infos['interface'], enabled))
		continue
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb75304ac>}
nname: 6
n 6(None)[__metaclass__ = MetaSingleton
def __init__(self):
	self.wn_gen = wn.NetGeneral()
	self.wn_dev = wn.NetDevices()
	self.wn_net = wn.NetNetworks()
	self.wn_cfg = wn.NetConfigurations()

def attach(self, obs):
	self.wn_gen.attach(obs)
	self.wn_dev.attach(obs)
	self.wn_net.attach(obs)

def detach(self, obs):
	self.wn_gen.detach(obs)
	self.wn_dev.detach(obs)
	self.wn_net.detach(obs)

def availables_networkType(self):
	try:
		pass

def wireless(self):
	return '802.11' in self.availables_networkType()

def get_configs(self):
	cfgs = []
	net_types = self.availables_networkType()
	try:

def new_config(self, name=None, ConfigurationInfos=None):
	return WyNetworkConfig(name=name, ConfigurationInfos=ConfigurationInfos)

def delete_config(self, config):
	log.debug(config)
	if not isinstance(config, WyNetworkConfig):
		raise Exception('config must be a WyNetworkConfig')
	if not self.wn_cfg.deleteConfiguration(config.name):
		raise Exception('deleteConfiguration() failed')

def save_config(self, config):
	log.debug(config)
	if not isinstance(config, WyNetworkConfig):
		raise Exception('config must be a WyNetworkConfig')
	if not config.is_valid():
		raise Exception('invalid keys: %s', config.invalids_keys())
	if config.name not in self.wn_cfg.getConfigurations():
		if not self.wn_cfg.addConfiguration(config.name):
			raise Exception('addConfiguration(%s) failed' % config.name)
	if not self.wn_cfg.setConfigurationInfos(config.name, config.config):
		raise Exception('setConfigurationInfos(%s, %s) failed' % (config.name, config.config))

def active_config(self, config):
	log.debug(config)
	if not isinstance(config, WyNetworkConfig):
		raise Exception('config must be a WyNetworkConfig')
	if not config.is_valid():
		raise Exception('config is not valid')
	if not self.wn_cfg.setActiveConfiguration(config.name):
		raise Exception('setActiveConfiguration() failed')

def autofill(self, config, key):
	invalids = config.invalids_keys()
	if key == 'interface' and key in invalids:
		config['interface'] = self.wn_dev.getDevicesByType(config['networkType'])[0]['interface']

def get_networks(self):
	nets = []
	try:

def set_scanning(self, enabled):
	for dev_infos in self.wn_dev.getDevicesByType('802.11'):
		if not self.wn_dev.setScanningEnabled(dev_infos['interface'], enabled):
			raise Exception('setScanningEnabled(%s, %s) failed' % (dev_infos['interface'], enabled))
			continue

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb753f64c>}
nname: 476
n 476(None)[]:
	i: 416(), 475()
	o: 

nname: 475
n 475(None)[]:
	i: 0(f)
	o: 476()

nname: 416
n 416(None)[net = WyNetwork()
new_cfg = net.new_config()
net_list = net.get_networks()
import pdb
pdb.set_trace()
]:
	i: 0(t)
	o: 476()

nname: 0
n 0(__name__ == '__main__')[__doc__ = "\ntemplates values:\n\n('val1', 'val2') : mandatory, accepted values in tuple\n(): mandatory, accept all values (must be a string)\n('val1', 'val2', None): optional, accepted values in tuple\n(None,): optional, accept all values (must be a string)\n"
from copy import copy
from peewee.misc_utils import MetaSingleton
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
import wynetwork as wn
log = GET_LOGGER(__name__)
tpl_base = {'active': ('false', 'true'), 'networkType': ('802.3', '802.11'), 'ipConfigType': ('upnp', 'static'), 'interface': ()}
tpl_updaters = {'01_networkType_802.11': {'essid': (), 'hidden': ('false', 'true', None), 'authType': ('WEP', 'WPA', 'WPA2', None)}, '02_hidden_true': {'authType': ('WEP', 'WPA', 'WPA2')}, '03_authType_WEP': {'cipher': ('WEP40', 'WEP104'), 'key': ()}, '04_authType_WPA': {'cipher': ('TKIP', 'CCMP'), 'keyMgmt': ('PSK',), 'key': ()}, '05_authType_WPA2': {'cipher': ('TKIP', 'CCMP'), 'keyMgmt': ('PSK',), 'key': ()}, '06_ipConfigType_static': {'ipAddress': (), 'netmask': (), 'gateway': (None,), 'dns1': (None,), 'dns2': (None,)}}
invalids_keys_order = ('networkType', 'essid', 'interface', 'authType', 'cipher', 'keyMgmt', 'key', 'ipConfigType', 'ipAddress', 'netmask')
default_config = {'active': 'false'}
class WyNetworkConfig(object):
	__doc__ = ' Use it to build a valid Wynetwork configuration. '
	def __init__(self, name=None, ConfigurationInfos=None):
		self.name = name
		if ConfigurationInfos and isinstance(ConfigurationInfos, dict):
			self.config = ConfigurationInfos
		else:
			self.config = copy(default_config)
		self.template = None
		return None

	def _get_autoname(self):
		_name = ''
		if self.config.get('networkType', '') == '802.3':
			_name = 'Eth'
		else:
			if self.config.get('networkType', '') == '802.11':
				_name = 'Wifi'
				_name += '-%s' % self.config.get('essid', '')
		if self.config.get('ipConfigType', '') == 'upnp':
			_name += '-auto'
		else:
			if self.config.get('ipConfigType', '') == 'static':
				_name += '-man'
		return _name

	autoname = property(_get_autoname)
	del _get_autoname
	def cleanup(self):
		for key in self.config.keys():
			if key not in self.template:
				del self.config[key]
				continue

	def _update_template(self):
		self.template = copy(tpl_base)

	def __repr__(self):
		return '<%s::%s:%s %s>' % (self.__class__.__name__, repr(self.name), repr(self.autoname), self.config)

	def __setitem__(self, key, value):
		self.config[key] = value

	def __getitem__(self, key):
		return self.config[key]

	def __contains__(self, key):
		return key in self.config

	def _valid_key(self, key):
		t_val = self.template[key]
		if not isinstance(t_val, tuple):
			log.error('template[%s] is not a tuple: %s', key, t_val)
			return False
		else:
			can_be_ommitted = None in t_val
			try:
				c_val = self.config[key]
			except KeyError:
				return can_be_ommitted
			else:
				if not isinstance(c_val, basestring) or c_val == '':
					return False
				if c_val in t_val:
					return True
				else:
					if t_val == ():
						return True
		return False

	def set_ethernet(self):
		self.config['networkType'] = '802.3'
		self._update_template()

	def set_network(self, NetworkInfos):
		self.config['networkType'] = '802.11'
		self._update_template()
		if NetworkInfos:
			for net_key, net_value in NetworkInfos.iteritems():
				if net_key in self.template and net_value != '':
					self.config[net_key] = net_value
					self._update_template()
					continue
		else:
			self.config['hidden'] = 'true'
			log.debug('set hidden = true')
			self._update_template()
		log.debug('template: %s', self.template)

	def configurator(self):
		log.debug('init')
		yield None
		invalids = self.invalids_keys()
		log.debug('start invalids=%s', invalids)
		while invalids:
			yield invalids[0]
			invalids_new = self.invalids_keys()
			log.debug('invalids_new=%s', invalids_new)
			if invalids_new != invalids:
				invalids = invalids_new
				continue
			log.error('invalids dont change: configuration failed')
			raise StopIteration

	def invalids_keys(self):
		self._update_template()

	def is_valid(self):
		try:
			if not self.invalids_keys() and self.name and len(self.name) > 0:
				return True
			else:
				return False

	def is_removable(self):
		if self.name and self.name in ('Wireless', 'Ethernet'):
			return False
		return True



class WyNetwork(object):
	__metaclass__ = MetaSingleton
	def __init__(self):
		self.wn_gen = wn.NetGeneral()
		self.wn_dev = wn.NetDevices()
		self.wn_net = wn.NetNetworks()
		self.wn_cfg = wn.NetConfigurations()

	def attach(self, obs):
		self.wn_gen.attach(obs)
		self.wn_dev.attach(obs)
		self.wn_net.attach(obs)

	def detach(self, obs):
		self.wn_gen.detach(obs)
		self.wn_dev.detach(obs)
		self.wn_net.detach(obs)

	def availables_networkType(self):
		try:
			pass

	def wireless(self):
		return '802.11' in self.availables_networkType()

	def get_configs(self):
		cfgs = []
		net_types = self.availables_networkType()
		try:

	def new_config(self, name=None, ConfigurationInfos=None):
		return WyNetworkConfig(name=name, ConfigurationInfos=ConfigurationInfos)

	def delete_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not self.wn_cfg.deleteConfiguration(config.name):
			raise Exception('deleteConfiguration() failed')

	def save_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not config.is_valid():
			raise Exception('invalid keys: %s', config.invalids_keys())
		if config.name not in self.wn_cfg.getConfigurations():
			if not self.wn_cfg.addConfiguration(config.name):
				raise Exception('addConfiguration(%s) failed' % config.name)
		if not self.wn_cfg.setConfigurationInfos(config.name, config.config):
			raise Exception('setConfigurationInfos(%s, %s) failed' % (config.name, config.config))

	def active_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not config.is_valid():
			raise Exception('config is not valid')
		if not self.wn_cfg.setActiveConfiguration(config.name):
			raise Exception('setActiveConfiguration() failed')

	def autofill(self, config, key):
		invalids = config.invalids_keys()
		if key == 'interface' and key in invalids:
			config['interface'] = self.wn_dev.getDevicesByType(config['networkType'])[0]['interface']

	def get_networks(self):
		nets = []
		try:

	def set_scanning(self, enabled):
		for dev_infos in self.wn_dev.getDevicesByType('802.11'):
			if not self.wn_dev.setScanningEnabled(dev_infos['interface'], enabled):
				raise Exception('setScanningEnabled(%s, %s) failed' % (dev_infos['interface'], enabled))
				continue



]:
	i: 
	o: 416(t), 475(f)

nname: 0
n 0(None)[__doc__ = "\ntemplates values:\n\n('val1', 'val2') : mandatory, accepted values in tuple\n(): mandatory, accept all values (must be a string)\n('val1', 'val2', None): optional, accepted values in tuple\n(None,): optional, accept all values (must be a string)\n"
from copy import copy
from peewee.misc_utils import MetaSingleton
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
import wynetwork as wn
log = GET_LOGGER(__name__)
tpl_base = {'active': ('false', 'true'), 'networkType': ('802.3', '802.11'), 'ipConfigType': ('upnp', 'static'), 'interface': ()}
tpl_updaters = {'01_networkType_802.11': {'essid': (), 'hidden': ('false', 'true', None), 'authType': ('WEP', 'WPA', 'WPA2', None)}, '02_hidden_true': {'authType': ('WEP', 'WPA', 'WPA2')}, '03_authType_WEP': {'cipher': ('WEP40', 'WEP104'), 'key': ()}, '04_authType_WPA': {'cipher': ('TKIP', 'CCMP'), 'keyMgmt': ('PSK',), 'key': ()}, '05_authType_WPA2': {'cipher': ('TKIP', 'CCMP'), 'keyMgmt': ('PSK',), 'key': ()}, '06_ipConfigType_static': {'ipAddress': (), 'netmask': (), 'gateway': (None,), 'dns1': (None,), 'dns2': (None,)}}
invalids_keys_order = ('networkType', 'essid', 'interface', 'authType', 'cipher', 'keyMgmt', 'key', 'ipConfigType', 'ipAddress', 'netmask')
default_config = {'active': 'false'}
class WyNetworkConfig(object):
	__doc__ = ' Use it to build a valid Wynetwork configuration. '
	def __init__(self, name=None, ConfigurationInfos=None):
		self.name = name
		if ConfigurationInfos and isinstance(ConfigurationInfos, dict):
			self.config = ConfigurationInfos
		else:
			self.config = copy(default_config)
		self.template = None
		return None

	def _get_autoname(self):
		_name = ''
		if self.config.get('networkType', '') == '802.3':
			_name = 'Eth'
		else:
			if self.config.get('networkType', '') == '802.11':
				_name = 'Wifi'
				_name += '-%s' % self.config.get('essid', '')
		if self.config.get('ipConfigType', '') == 'upnp':
			_name += '-auto'
		else:
			if self.config.get('ipConfigType', '') == 'static':
				_name += '-man'
		return _name

	autoname = property(_get_autoname)
	del _get_autoname
	def cleanup(self):
		for key in self.config.keys():
			if key not in self.template:
				del self.config[key]
				continue

	def _update_template(self):
		self.template = copy(tpl_base)

	def __repr__(self):
		return '<%s::%s:%s %s>' % (self.__class__.__name__, repr(self.name), repr(self.autoname), self.config)

	def __setitem__(self, key, value):
		self.config[key] = value

	def __getitem__(self, key):
		return self.config[key]

	def __contains__(self, key):
		return key in self.config

	def _valid_key(self, key):
		t_val = self.template[key]
		if not isinstance(t_val, tuple):
			log.error('template[%s] is not a tuple: %s', key, t_val)
			return False
		else:
			can_be_ommitted = None in t_val
			try:
				c_val = self.config[key]
			except KeyError:
				return can_be_ommitted
			else:
				if not isinstance(c_val, basestring) or c_val == '':
					return False
				if c_val in t_val:
					return True
				else:
					if t_val == ():
						return True
		return False

	def set_ethernet(self):
		self.config['networkType'] = '802.3'
		self._update_template()

	def set_network(self, NetworkInfos):
		self.config['networkType'] = '802.11'
		self._update_template()
		if NetworkInfos:
			for net_key, net_value in NetworkInfos.iteritems():
				if net_key in self.template and net_value != '':
					self.config[net_key] = net_value
					self._update_template()
					continue
		else:
			self.config['hidden'] = 'true'
			log.debug('set hidden = true')
			self._update_template()
		log.debug('template: %s', self.template)

	def configurator(self):
		log.debug('init')
		yield None
		invalids = self.invalids_keys()
		log.debug('start invalids=%s', invalids)
		while invalids:
			yield invalids[0]
			invalids_new = self.invalids_keys()
			log.debug('invalids_new=%s', invalids_new)
			if invalids_new != invalids:
				invalids = invalids_new
				continue
			log.error('invalids dont change: configuration failed')
			raise StopIteration

	def invalids_keys(self):
		self._update_template()

	def is_valid(self):
		try:
			if not self.invalids_keys() and self.name and len(self.name) > 0:
				return True
			else:
				return False

	def is_removable(self):
		if self.name and self.name in ('Wireless', 'Ethernet'):
			return False
		return True



class WyNetwork(object):
	__metaclass__ = MetaSingleton
	def __init__(self):
		self.wn_gen = wn.NetGeneral()
		self.wn_dev = wn.NetDevices()
		self.wn_net = wn.NetNetworks()
		self.wn_cfg = wn.NetConfigurations()

	def attach(self, obs):
		self.wn_gen.attach(obs)
		self.wn_dev.attach(obs)
		self.wn_net.attach(obs)

	def detach(self, obs):
		self.wn_gen.detach(obs)
		self.wn_dev.detach(obs)
		self.wn_net.detach(obs)

	def availables_networkType(self):
		try:
			pass

	def wireless(self):
		return '802.11' in self.availables_networkType()

	def get_configs(self):
		cfgs = []
		net_types = self.availables_networkType()
		try:

	def new_config(self, name=None, ConfigurationInfos=None):
		return WyNetworkConfig(name=name, ConfigurationInfos=ConfigurationInfos)

	def delete_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not self.wn_cfg.deleteConfiguration(config.name):
			raise Exception('deleteConfiguration() failed')

	def save_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not config.is_valid():
			raise Exception('invalid keys: %s', config.invalids_keys())
		if config.name not in self.wn_cfg.getConfigurations():
			if not self.wn_cfg.addConfiguration(config.name):
				raise Exception('addConfiguration(%s) failed' % config.name)
		if not self.wn_cfg.setConfigurationInfos(config.name, config.config):
			raise Exception('setConfigurationInfos(%s, %s) failed' % (config.name, config.config))

	def active_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not config.is_valid():
			raise Exception('config is not valid')
		if not self.wn_cfg.setActiveConfiguration(config.name):
			raise Exception('setActiveConfiguration() failed')

	def autofill(self, config, key):
		invalids = config.invalids_keys()
		if key == 'interface' and key in invalids:
			config['interface'] = self.wn_dev.getDevicesByType(config['networkType'])[0]['interface']

	def get_networks(self):
		nets = []
		try:

	def set_scanning(self, enabled):
		for dev_infos in self.wn_dev.getDevicesByType('802.11'):
			if not self.wn_dev.setScanningEnabled(dev_infos['interface'], enabled):
				raise Exception('setScanningEnabled(%s, %s) failed' % (dev_infos['interface'], enabled))
				continue



if __name__ == '__main__':
	net = WyNetwork()
	new_cfg = net.new_config()
	net_list = net.get_networks()
	import pdb
	pdb.set_trace()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb752a7ac>}
__doc__ = "\ntemplates values:\n\n('val1', 'val2') : mandatory, accepted values in tuple\n(): mandatory, accept all values (must be a string)\n('val1', 'val2', None): optional, accepted values in tuple\n(None,): optional, accept all values (must be a string)\n"
from copy import copy
from peewee.misc_utils import MetaSingleton
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
import wynetwork as wn
log = GET_LOGGER(__name__)
tpl_base = {'active': ('false', 'true'), 'networkType': ('802.3', '802.11'), 'ipConfigType': ('upnp', 'static'), 'interface': ()}
tpl_updaters = {'01_networkType_802.11': {'essid': (), 'hidden': ('false', 'true', None), 'authType': ('WEP', 'WPA', 'WPA2', None)}, '02_hidden_true': {'authType': ('WEP', 'WPA', 'WPA2')}, '03_authType_WEP': {'cipher': ('WEP40', 'WEP104'), 'key': ()}, '04_authType_WPA': {'cipher': ('TKIP', 'CCMP'), 'keyMgmt': ('PSK',), 'key': ()}, '05_authType_WPA2': {'cipher': ('TKIP', 'CCMP'), 'keyMgmt': ('PSK',), 'key': ()}, '06_ipConfigType_static': {'ipAddress': (), 'netmask': (), 'gateway': (None,), 'dns1': (None,), 'dns2': (None,)}}
invalids_keys_order = ('networkType', 'essid', 'interface', 'authType', 'cipher', 'keyMgmt', 'key', 'ipConfigType', 'ipAddress', 'netmask')
default_config = {'active': 'false'}
class WyNetworkConfig(object):
	__doc__ = ' Use it to build a valid Wynetwork configuration. '
	def __init__(self, name=None, ConfigurationInfos=None):
		self.name = name
		if ConfigurationInfos and isinstance(ConfigurationInfos, dict):
			self.config = ConfigurationInfos
		else:
			self.config = copy(default_config)
		self.template = None
		return None

	def _get_autoname(self):
		_name = ''
		if self.config.get('networkType', '') == '802.3':
			_name = 'Eth'
		else:
			if self.config.get('networkType', '') == '802.11':
				_name = 'Wifi'
				_name += '-%s' % self.config.get('essid', '')
		if self.config.get('ipConfigType', '') == 'upnp':
			_name += '-auto'
		else:
			if self.config.get('ipConfigType', '') == 'static':
				_name += '-man'
		return _name

	autoname = property(_get_autoname)
	del _get_autoname
	def cleanup(self):
		for key in self.config.keys():
			if key not in self.template:
				del self.config[key]
				continue

	def _update_template(self):
		self.template = copy(tpl_base)

	def __repr__(self):
		return '<%s::%s:%s %s>' % (self.__class__.__name__, repr(self.name), repr(self.autoname), self.config)

	def __setitem__(self, key, value):
		self.config[key] = value

	def __getitem__(self, key):
		return self.config[key]

	def __contains__(self, key):
		return key in self.config

	def _valid_key(self, key):
		t_val = self.template[key]
		if not isinstance(t_val, tuple):
			log.error('template[%s] is not a tuple: %s', key, t_val)
			return False
		else:
			can_be_ommitted = None in t_val
			try:
				c_val = self.config[key]
			except KeyError:
				return can_be_ommitted
			else:
				if not isinstance(c_val, basestring) or c_val == '':
					return False
				if c_val in t_val:
					return True
				else:
					if t_val == ():
						return True
		return False

	def set_ethernet(self):
		self.config['networkType'] = '802.3'
		self._update_template()

	def set_network(self, NetworkInfos):
		self.config['networkType'] = '802.11'
		self._update_template()
		if NetworkInfos:
			for net_key, net_value in NetworkInfos.iteritems():
				if net_key in self.template and net_value != '':
					self.config[net_key] = net_value
					self._update_template()
					continue
		else:
			self.config['hidden'] = 'true'
			log.debug('set hidden = true')
			self._update_template()
		log.debug('template: %s', self.template)

	def configurator(self):
		log.debug('init')
		yield None
		invalids = self.invalids_keys()
		log.debug('start invalids=%s', invalids)
		while invalids:
			yield invalids[0]
			invalids_new = self.invalids_keys()
			log.debug('invalids_new=%s', invalids_new)
			if invalids_new != invalids:
				invalids = invalids_new
				continue
			log.error('invalids dont change: configuration failed')
			raise StopIteration

	def invalids_keys(self):
		self._update_template()

	def is_valid(self):
		try:
			if not self.invalids_keys() and self.name and len(self.name) > 0:
				return True
			else:
				return False

	def is_removable(self):
		if self.name and self.name in ('Wireless', 'Ethernet'):
			return False
		return True



class WyNetwork(object):
	__metaclass__ = MetaSingleton
	def __init__(self):
		self.wn_gen = wn.NetGeneral()
		self.wn_dev = wn.NetDevices()
		self.wn_net = wn.NetNetworks()
		self.wn_cfg = wn.NetConfigurations()

	def attach(self, obs):
		self.wn_gen.attach(obs)
		self.wn_dev.attach(obs)
		self.wn_net.attach(obs)

	def detach(self, obs):
		self.wn_gen.detach(obs)
		self.wn_dev.detach(obs)
		self.wn_net.detach(obs)

	def availables_networkType(self):
		try:
			pass

	def wireless(self):
		return '802.11' in self.availables_networkType()

	def get_configs(self):
		cfgs = []
		net_types = self.availables_networkType()
		try:

	def new_config(self, name=None, ConfigurationInfos=None):
		return WyNetworkConfig(name=name, ConfigurationInfos=ConfigurationInfos)

	def delete_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not self.wn_cfg.deleteConfiguration(config.name):
			raise Exception('deleteConfiguration() failed')

	def save_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not config.is_valid():
			raise Exception('invalid keys: %s', config.invalids_keys())
		if config.name not in self.wn_cfg.getConfigurations():
			if not self.wn_cfg.addConfiguration(config.name):
				raise Exception('addConfiguration(%s) failed' % config.name)
		if not self.wn_cfg.setConfigurationInfos(config.name, config.config):
			raise Exception('setConfigurationInfos(%s, %s) failed' % (config.name, config.config))

	def active_config(self, config):
		log.debug(config)
		if not isinstance(config, WyNetworkConfig):
			raise Exception('config must be a WyNetworkConfig')
		if not config.is_valid():
			raise Exception('config is not valid')
		if not self.wn_cfg.setActiveConfiguration(config.name):
			raise Exception('setActiveConfiguration() failed')

	def autofill(self, config, key):
		invalids = config.invalids_keys()
		if key == 'interface' and key in invalids:
			config['interface'] = self.wn_dev.getDevicesByType(config['networkType'])[0]['interface']

	def get_networks(self):
		nets = []
		try:

	def set_scanning(self, enabled):
		for dev_infos in self.wn_dev.getDevicesByType('802.11'):
			if not self.wn_dev.setScanningEnabled(dev_infos['interface'], enabled):
				raise Exception('setScanningEnabled(%s, %s) failed' % (dev_infos['interface'], enabled))
				continue



if __name__ == '__main__':
	net = WyNetwork()
	new_cfg = net.new_config()
	net_list = net.get_networks()
	import pdb
	pdb.set_trace()
